<%@page import="com.grom.util.SecurityUtil"%>
<%@page import="com.grom.po.GcmsUser"%>
<%@page import="com.grom.po.Customer"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/js/themes/icon.css">
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.6.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.easyui.min.js"></script>
<script type="text/javascript">
$(function(){
	$('#loginInfoEdit').dialog({  
	    title : 'Customer Info',  
	    modal: true,  
	    collapsible : true,    
	    resizable : true   
	});  
	$('#loginInfoEdit').dialog('close');
});


function showAddDialog(){
	$('#loginInfoEdit').dialog('open');
}

function loginInfoEdit(){
	$('cusForm').submit();
	$('#loginInfoEdit').dialog('close');
}
function viewDetail(){
	var itemId =  $('#tt').datagrid('getSelected').itemid;
	$.ajax({
	    url: '<%=request.getContextPath()%>/CustomerAction/getDetail.do?itemid='+itemId,
	    type: 'GET',
	    timeout: 1000,
	    error: function(){
	        alert('Error getting response!');
	    },
	    success: function(json){
	        var customer = eval(json);
	        $('#ID').val(customer.ID);
	        $('#cusType').val(customer.cusType);
	        $('#brandName').val(customer.brandName);
	        $('#visitedAddress').val(customer.visitedAddress);
	        $('#customerName').val(customer.customerName);
	        $('#averageSale').val(customer.averageSale);
	        $('#storeNum').val(customer.storeNum);
	        $('#monthlyCoverNum').val(customer.monthlyCoverNum);
	        $('#monthlyCoverDay').val(customer.monthlyCoverDay);
	        $('#cusFlowCover').val(customer.cusFlowCover);
	        $('#cusFlowCoverWay').val(customer.cusFlowCoverWay);
	        $('#distanceStoreCover').val(customer.distanceStoreCover);
	        $('#distanceStoreCoverWay').val(customer.distanceStoreCoverWay);
	        $('#everUsedFlowCover').val(customer.everUsedFlowCover);
	        $('#everUsedDistanceStoreCover').val(customer.everUsedDistanceStoreCover);
	        $('#reasonOfNotUsed').val(customer.reasonOfNotUsed);
	        $('#wantUse').val(customer.wantUse);
	        $('#reasonOfRefuse').val(customer.reasonOfRefuse);
	        $('#importantFunction').val(customer.importantFunction);
	        $('#chargeWayWanted').val(customer.chargeWayWanted);
	        $('#cusFlowChargeWanted').val(customer.cusFlowChargeWanted);
	        $('#storeCoverChargeWanted').val(customer.storeCoverChargeWanted);
			$('#loginInfoEdit').dialog('open');
	    }
	});
}

function doSearch(){
	$('#searchForm').submit();
}
</script>
<title>查询页面</title>
</head>
<body>
<div style="font-size: 10px;">
<form id="searchForm" name="searchForm" action="<%=request.getContextPath() %>/QueryAction/doQuery.do" method="post">
      <label>客户分类：</label>  
      <select name="cusType_s" id="cusType_s" style="width: 40px;">
      		<option value="A">A</option>
      		<option value="B">B</option>
      		<option value="C">C</option>
      		<option value="D">D</option>
      </select>
      <label>品牌名称：</label>  
      <input type="text" name="brandName_s" id="brandName_s" ></input>  
      <label>销售人员：</label>  
       <select id="userId_s" name="userId_s" style="width:50px;">
                	<option value="">无</option>
                	<%
                		List<GcmsUser> users = SecurityUtil.getAllUser();
                		for(GcmsUser user : users){
                			%>
                			<option value="<%=user.getID() %>"><%=user.getUserName() %></option>
                			<%
                		}
                	%>
                </select>  
      <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="doSearch()">search</a>
</form>
</div>
<table id="tt" class="easyui-datagrid"  iconCls="icon-edit" style="height:500px"
        title="DataGrid with Toolbar" singleSelect="true"
        toolbar="#tb">  
    <thead>  
        <tr>  
            <th field="itemid" width="80">Item ID</th>  
            <th field="cusType" width="80">客户分类</th>  
            <th field="customerName" width="80" align="right">客户姓名</th>  
        </tr>  
    </thead>  
    <tbody>     
    	<%
    		List<Customer> allCustomer = (List<Customer>)request.getAttribute("allCustomer");
    		for(Customer customer : allCustomer){
    	%>
        <tr>                             
            <td><%=customer.getID() %></td>              
            <td><%=customer.getCusType() %></td>              
            <td><%=customer.getCustomerName() %></td>                    
        </tr>  
    	<%
    		}
    	%>                         
    </tbody>
</table>  
<div id="tb">  
	<% if(session.getAttribute("USER")!=null){ %>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cut" plain="true" onclick="viewDetail()">客户信息</a>  
    <a href="#" class="easyui-linkbutton" iconCls="icon-cut" plain="true" onclick="viewDetail()">品牌详细</a> 
    <a href="#" class="easyui-linkbutton" iconCls="icon-cut" plain="true" onclick="viewDetail()">店铺详细</a> 
	<% } %>
<!-- 
    <a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="doDelete()">Delete</a> 
 -->
</div>  



<!-- 编辑 -->  
<div id="loginInfoEdit"  
    style="padding: 5px; width: 600px; height: 450px;">  
    <h5 id="loginInfoEdit_message" style="color: red;"></h5>  
    <div class="ToolTip_Form" id="table_loginInfoEdit" onkeydown="if(event.keyCode==13){loginInfoEdit();}">  
       <form id="cusForm" name="cusForm" action="<%=request.getContextPath() %>/CustomerAction/doSaveForSearch.do" method="post">
       <input type="text" name="ID" id="ID" value="" style="display: none"/>
       <ul>    
            <li>  
                <label>客户分类：</label>  
                <input type="text" class="easyui-validatebox" name="cusType" id="cusType" maxlength="20" required="true"></input>  
            </li>  
            <li>  
                <label>品牌名称：</label>  
                <input type="text" class="easyui-validatebox" name="brandName" id="brandName" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>受访地址：</label>  
                <input type="text" class="easyui-validatebox" name="visitedAddress" id="visitedAddress" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>客户姓名：</label>  
                <input type="text" class="easyui-validatebox" name="customerName" id="customerName" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>店铺每月平均销售额：</label>  
                <input type="text" class="easyui-validatebox" name="averageSale" id="averageSale" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>管理/经营店铺数量：</label>  
                <input type="text" class="easyui-validatebox" name="storeNum" id="storeNum" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>每月巡店数量：</label>  
                <input type="text" class="easyui-validatebox" name="monthlyCoverNum" id="monthlyCoverNum" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>每月巡店天数：</label>  
                <input type="text" class="easyui-validatebox" name="monthlyCoverDay" id="monthlyCoverDay" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>是否知道客流统计：</label>  
                <input type="text" class="easyui-validatebox" name="cusFlowCover" id="cusFlowCover" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>通过何种方式知道：</label>  
                <input type="text" class="easyui-validatebox" name="cusFlowCoverWay" id="cusFlowCoverWay" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>是否知道远程巡店：</label>  
                <input type="text" class="easyui-validatebox" name="distanceStoreCover" id="distanceStoreCover" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>通过何种渠道知道：</label>  
                <input type="text" class="easyui-validatebox" name="distanceStoreCoverWay" id="distanceStoreCoverWay" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>是否使用过客流统计：</label>  
                <input type="text" class="easyui-validatebox" name="everUsedFlowCover" id="everUsedFlowCover" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>是否使用过远程巡店：</label>  
                <input type="text" class="easyui-validatebox" name="everUsedDistanceStoreCover" id="everUsedDistanceStoreCover" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>没有使用的原因：</label>  
                <input type="text" class="easyui-validatebox" name="reasonOfNotUsed" id="reasonOfNotUsed" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>近期是否想使用：</label>  
                <input type="text" class="easyui-validatebox" name="wantUse" id="wantUse" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>不想使用的原因：</label>  
                <input type="text" class="easyui-validatebox" name="reasonOfRefuse" id="reasonOfRefuse" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>何种功能最重要：</label>  
                <input type="text" class="easyui-validatebox" name="importantFunction" id="importantFunction" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>希望客流统计价格收取方式：</label>  
                <input type="text" class="easyui-validatebox" name="chargeWayWanted" id="chargeWayWanted" maxlength="20" required="true"></input>  
            </li> 
            <li>  
                <label>合理的客流统计购买价格：</label>  
                <input type="text" class="easyui-validatebox" name="cusFlowChargeWanted" id="cusFlowChargeWanted" maxlength="20" required="true"></input>  
            </li> 
             <li>  
                <label>合理的视频巡店购买价格：</label>  
                <input type="text" class="easyui-validatebox" name="storeCoverChargeWanted" id="storeCoverChargeWanted" maxlength="20" required="true"></input>  
            </li> 
            <li>  
            	<a href="#" class="easyui-linkbutton" onclick="$('#cusForm').submit();">保存</a>
            	<a href="#" class="easyui-linkbutton" onclick="$('#loginInfoEdit').dialog('close');">放弃操作</a>
            </li>  
        </ul>  
       </form>
    </div>  
</div>  
</body>
</html>